package com.ycq.controller;

import com.ycq.model.User1;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//@Log4j
@RestController
@Api(value = "v1",description = "这是我的第一个版本的demo")
@RequestMapping("v1")
public class Demo {

    //获取一个执行sql预计的对象
    @Autowired
    private SqlSessionTemplate template;

    @RequestMapping(value = "/getUserCount",method = RequestMethod.GET)
    @ApiOperation(value = "可以获取用户数",httpMethod = "get")
    public int getUserCount(){
       return template.selectOne("getuserCount");
    }

    @RequestMapping(value = "/addUser",method = RequestMethod.POST)
    @ApiOperation(value = "增加数据接口",httpMethod = "post")
    public int addUser(@RequestBody User1 user1){
        int s=template.insert("addUser", user1);
        return s;
    }

    @RequestMapping(value = "/updataUser",method = RequestMethod.POST)
    public int updataUser(@RequestBody User1 user1){

       return template.update("updateUser", user1);
    }

    @RequestMapping(value = "/delUser",method = RequestMethod.POST)
    public int delUser(@RequestParam int id) {

        return template.delete("delUser",id);
    }

}
